<template>
    <el-container>
        <el-container>
            <el-header>
                <img src="@/assets/logo1.png" class="logo" />
                <el-row class="user">
                    <el-col :span="6">
                        <img src="@/assets/user.png" />
                    </el-col>
                    <div v-if="expire">
                        <el-col :span="6">欢迎</el-col>
                        <el-col :span="8">{{token.username}}</el-col>
                    </div>
                    <div v-else>未登录</div>

                    <el-col :span="4">&nbsp;</el-col>
                </el-row>
            </el-header>
            <el-container>
                <Aside />
                <el-main>
                    <template>
                        <router-view />
                    </template>
                </el-main>
            </el-container>
            <el-footer>Footer</el-footer>
        </el-container>
    </el-container>
</template>

<script>
import jwtDecode from "jwt-decode";
import Aside from "@/components/aside/index.vue";
export default {
    created() {
        // 获取秒级时间戳
        if (this.token.exp < (Math.round(new Date() / 1000))) {
            this.expire = false;
            console.log("过期了")
        }
    },
    data() {
        return {
            expire: true,
            token: jwtDecode(localStorage.getItem("JWT_TOKEN"))
        };
    },
    name: "home",
    components: {
        Aside
    }
};
</script>
<style scoped>
.logo {
    height: 60px;
    float: left;
}
.user {
    float: right;
    margin-top: 5px;
    width: 200px;
}
.el-header,
.el-footer {
    padding: 0px;
    background-color: #b3c0d1;
    color: #333;
    text-align: center;
    line-height: 60px;
}
.el-main {
    background-color: fff;
    color: #111;
    /* text-align: center; */
    line-height: 50px;
    padding: 0px;
}
</style>
